/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package com.sree.tali.dao.homepage.impl;

import com.sree.tali.hibernate.pojo.QuestionPojo;
import java.util.ArrayList;
import java.util.List;
import org.hibernate.Query;
import org.hibernate.Session;
import org.hibernate.Transaction;

/**
 *
 * @author LENOVO
 */
public class QuestionDaoImpl implements QuestionDao {

    @Override
    public void addBit(QuestionPojo questionpojo, Session session) {
        try {
        Transaction tx = session.beginTransaction();
        session.save(questionpojo);
        tx.commit();
        }
        catch(Exception ex)
        {
            ex.printStackTrace();
        }
    }

    @Override
    public List<QuestionPojo> showbits(String category, Session session) {
        List<QuestionPojo> questionpojolist = new ArrayList<QuestionPojo>();
        try {
            String qry = "from QuestionPojo where category like '%"+category+"%'";
            Query query = session.createQuery(qry);
            questionpojolist =( List<QuestionPojo>) query.list();
            
        }
        catch(Exception ex)
        {
            ex.printStackTrace();
        }  
        return questionpojolist;
    }

    @Override
    public void updateBit(int id, Session session) {
        QuestionPojo qpojo=(QuestionPojo)session.load(QuestionPojo.class, id);
        throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
    }
    
}
